/*
 * GraphNode.cpp
 *
 *  Created on: 14/11/2011
 *      Author: will
 */

#include <opencv/cv.h>
#include "GraphNode.h"

GraphEdge* GraphNode::addEdgeTo(GraphNode* dest, Vector3d odometry,
		Matrix3d icov) {
	GraphEdge* edge = new GraphEdge();
	edge->frameNum = this->frameNum;
	edge->odometry = odometry;
	edge->icov = icov;
	edge->nodeFrom = this;
	edge->nodeTo = dest;
	this->edgeTo.push_back(edge);
	dest->edgeFrom.push_back(edge);
	return edge;
}

GraphNode::GraphNode(int frameNum, Mat* descriptors, Bagofwords* bagOfWords, string descriptorPath) {
	this->frameNum = frameNum;
	this->descriptors = descriptors;
	this->bagOfWords = bagOfWords;
	this->descriptorPath = descriptorPath;
	edgeFrom.clear();
	edgeTo.clear();
}
/*
double GraphNode::updateInformation() {
	LocalGraph *localGraph = new LocalGraph(this,1);



}*/

GraphNode::GraphNode() {
	frameNum = 0;
	descriptors = NULL;
	bagOfWords = NULL;
	descriptorPath.erase();
	bestParents.first = NULL;
	bestParents.second = NULL;
	edgeFrom.clear();
	edgeTo.clear();
}

GraphNode::~GraphNode() {
	//if (descriptors != NULL)
	//	descriptors->release();
	//if (bagOfWords != NULL)
	//	delete bagOfWords;
}

GraphNode::GraphNode(const GraphNode & other) {
	frameNum = other.frameNum;
	position = other.position;
	descriptors = other.descriptors;
	bagOfWords = other.bagOfWords;
	descriptorPath = other.descriptorPath;
	edgeFrom = other.edgeFrom;
	edgeTo = other.edgeTo;
	odoLikelihood = other.odoLikelihood;
	visLikelihood = other.visLikelihood;
	bestParents = other.bestParents;
}

GraphNode & GraphNode::operator=(const GraphNode & other) {
	frameNum = other.frameNum;
	position = other.position;
	descriptors = other.descriptors;
	bagOfWords = other.bagOfWords;
	descriptorPath = other.descriptorPath;
	edgeFrom = other.edgeFrom;
	edgeTo = other.edgeTo;
	odoLikelihood = other.odoLikelihood;
	visLikelihood = other.visLikelihood;
	bestParents = other.bestParents;
	return *this;
}
